import re


def validate_user_data(data):
    errors = []

    # 验证用户名
    if 'username' not in data or not data['username']:
        errors.append('Username is required')
    elif len(data['username']) < 3:
        errors.append('Username must be at least 3 characters')

    # 验证邮箱
    if 'email' not in data or not data['email']:
        errors.append('Email is required')
    elif not re.match(r"[^@]+@[^@]+\.[^@]+", data['email']):
        errors.append('Invalid email format')

    return errors

